impl Solution {
    pub fn min_moves(mut target: i32,mut max_doubles: i32) -> i32 {
        let mut ans=0;
        while target>1{
            if target&1==1{
                ans+=1;
                target-=1;
                continue;
            }
            if max_doubles>0{
                max_doubles-=1;
                target>>=1;
                ans+=1;
            }else{
                ans+=target-1;
                return  ans;
            }
        }
        return ans;
    }
}

